﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using TA.DotNetUtils;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// The container for all indexed page buttons in a Repeater.
	/// </summary>
	public class RepeaterPagesButtonsContainer : BaseRepeaterControl
	{
		/// <summary>
		/// Ctor.
		/// </summary>
		/// <param name="repeater"></param>
		internal RepeaterPagesButtonsContainer(Repeater repeater)
			: base(repeater)
		{
			this._button = new RepeaterPageButtonNormal(repeater);
			this.Controls.Add(this._button);
		}
		/// <summary>
		/// Renders the control.
		/// </summary>
		/// <param name="writer"></param>
		public override void RenderControl(HtmlTextWriter writer)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Class, "pages");
			writer.RenderBeginTag(HtmlTextWriterTag.Span);

			IntRange pagesRange = this.Repeater.PagesRange;
			for (int i = pagesRange.Start; i < pagesRange.End; ++i)
			{
				this._button.SetIndex(i);
				this._button.RenderControl(writer);
			}

			writer.RenderEndTag();
		}
		RepeaterPageButtonNormal _button;
	}
}